home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1994 November / macformat-018.iso / Utility Spectacular / Developer / QB->FB / QB-FB Instructions < prev    next >
Encoding:
Text File  |  1993-02-23  |  10.6 KB  |  154 lines  |  [TEXT/MSWD]

  1.  
  2. QuickBASIC™ to FutureBASIC™ Conversion Instructions
  3.  
  4. ------------------------------------------------------
  5.  
  6. This program consists of four files:
  7.  
  8. QB->FB Instructions — A read me file containing pointers and notes concerning these files and the translation process.
  9.  
  10. QB Convert.BAS — source code of conversion program
  11.  
  12. QB->FB.data — the actual conversion data required to successfully convert a keyword in QuickBASIC to FutureBASIC syntax
  13.  
  14. qbCLR.INCL — an Include file containing functions that mimic the majority of Clear Lake Research calls that are not simple Toolbox translations.
  15.  
  16.  
  17. ------------------------------------------------------
  18.  
  19. WHAT THIS PROGRAM CAN DO:
  20.  
  21. This conversion program will translate a QuickBASIC source code file saved in TEXT format into a source code TEXT file FutureBASIC can use. It will convert approximately 80% of the QB keywords into FB syntax including a majority of CLR and Toolbox calls. It will also convert multi-line IF/THEN statements into FB's LONG IF structures, change multi-statement lines containing colons into single lines. Additionaly, it will convert QB  subroutine labels to FB format and convert SUBs into LOCAL FNs.
  22.  
  23. It also attempts to mark every statement not converted with appropriate references to the Reference or Handbook manuals for help in fixing your source code.
  24.  
  25.  
  26. ------------------------------------------------------
  27.  
  28. WHAT THIS PROGRAM CANNOT DO:
  29.  
  30. It cannot deduce your program structure. While every attempt has been made to make it as robust as possible in converting parameters, finding labels, and changing SUBs to LOCAL FNs, your method of programming can cause subtle errors to creep into the translated program.
  31.  
  32. Additionally, it does not attempt to rewrite any file handling routines included in the source file. There are just too many variables to trust an accurate translation and re-writing them is best left to the programmer to ensure the results are what they expect.
  33.  
  34. ALWAYS WORK ON A TEXT COPY OF THE ORIGINAL.
  35.  
  36. If errors are present feel free to modify the source code to correct these deficiencies. The source code is provided AS IS with no guarantee of any results. The majority of routines have been documented to provide as much help as possible to make additions or changes relatively easy. Again, feel free to change or modify as necessary to best suit your purposes. If you do, please drop us a copy so that we can share it with others.
  37.  
  38. If you do modify the program, please append this documentation with any changes, and if distributing it to others, be sure to include ALL the files mentioned above to keep the package complete for the next user.
  39.  
  40. ------------------------------------------------------
  41.  
  42. HOW IT DOES WHAT IT DOES:
  43.  
  44. This program is designed to help you convert the majority of a QuickBASIC program to FutureBASIC format. It does this using several passes through the source code and goes something like this:
  45.  
  46.  
  47. Pass 1. Requests you to select a source file to convert (must be in TEXT format), then reads the file into an INDEX$ array, stripping any source remarks as it goes (don't worry, they'll be added back later) into anoth INDEX$ array.
  48.  
  49.  
  50. Pass 2. A reference table is created for all GOSUB, GOTO, THEN and inferred THEN label references, and SUB references. All QB labels are converted to FB's double-quote format. Any case variations are accounted for. i.e. Fred and FRED are considered the same. This also applies to SUB references. All SUB references are converted to FN to match FB's subroutine format.
  51.  
  52.  
  53. Pass 3: All single line IF/THEN statements and multi-line IF/ELSEIF/END IF lines are reformated into LONG IF/XELSE/END IF format.
  54.  
  55.  
  56. Pass 4: Any remaining multi-statement lines are now broken into separate lines.
  57.  
  58.  
  59. Pass 5. The next pass is made that converts all incompatable keywords. This is done by accessing the TEXT file called "QB->FB.data".  This file can be modified to convert other keywords.
  60.  
  61. Each keyword to convert requires two sequencial lines in the conversion file. The first line containing the QB syntax, the second the FB syntax. Each QB line is preceded by a special character that identifies the type of keyword to convert. Each parameter is represented by a number, itself preceded by the tilde (~) character.
  62.  
  63. The keyword codes have the following meanings:
  64.  
  65. ^    (caret symbol, an insert note) Add the text on the next line to the front of the line. For example, in the following:
  66.  
  67.     ^CLEAR
  68.     • different, see Ref-70 -->
  69.  
  70. When the conversion program gets to the line "CLEAR 2000" in the QB source file, it will convert it to:
  71.  
  72.     • different, see Ref-70 --> CLEAR 2000
  73.  
  74. If you attempt the run the converted program, this line will generate a syntax error, forcing you to deal with converting it manually.  In most cases the difference between the QB form of the keyword and the FB form can have significant effects on the behavior of the program and should be dealt with manually. For example, QB uses the keyword "LINE" to draw lines and boxes, FB, however, uses "LINE" to return the address of a subroutine in memory.
  75.  
  76.  
  77. @    (at symbol, convert w/o parenthesis) This is used with statements that have no paretheses around the parameter list. This directs the conversion program to translate the keyword directly and transfer parameters as indicated. For example, it is used with the LOCATE statement using this format:
  78.  
  79.     @LOCATE ~1,~2
  80.     LOCATE ~2,~1
  81.  
  82. FutureBASIC uses the format horz, vert and QB uses the format vert, horz.
  83.  
  84. Note the use of the tilde symbol (~) to identify the parameters in the keyword. Use of this symbol in the parameter list ensures that the correct parameter is replaced during the conversion. It is used throughout the data file to identify parameters and by the conversion program to search for parameter matches. Change at your own peril!
  85.  
  86.  
  87. #    (pound symbol, convert w/parenthesis) This identifies statements that have parentheses around the parameter list. It directs the conversion program to translate the keyword directly and transfer parameters as indicated. It needs to know about the parentheses around the parameters so that parsing is done correctly.
  88.  
  89.  
  90. *    (asterisk, a toolbox call or function) This is used with the toolbox type commands supported by QB (yes, even Clear Lake's library of stuff). It will convert toolbox commands whether or not they use CALL with parenthesis or no CALL and no parenthesis.
  91.  
  92. Note that CALL and parenthesis should not be used on the QB conversion line. For example, while CALL FILLPGONHDL (p&, h&) and fillPgonHdl p&,h& are both valid syntax in QB, the format for the conversion text file should be:
  93.  
  94.     *FILLPGONHDL ~1,~2
  95.     CALL FILLPOLY(~1,~2)
  96.  
  97. When dealing with functions, use this format:
  98.  
  99.     *GETICON ~1,~2,~3
  100.     ~3 = FN GETICON (~2)
  101.  
  102. In most cases the conversion of QB's toolbox support simply ensures that all procedures that uses CALL have it and that both functions and procedures have parenthesis around the parameter list.
  103.  
  104. For the Clear Lake Research support, in most cases, they have been converted to the direct toolbox functions or procedures. For example:
  105.  
  106. *INACTIVESCROLL ~1 CALL HILITECONTROL (~1, _false)
  107.  
  108. Many of the routines have no direct toolbox call, but are instead, a subroutine that performs an action.  The qbCLR.INCL file contains about a dozen LOCAL FNs that mimic the effects of some of the CLR routines. For example:
  109.  
  110. *ADDCURSOR ~1,~2,~3,~4 ~4 = FN qbAddCursor (~1,~2,~3)
  111.  
  112. Others have been left to implement at your discretion.
  113.  
  114.  
  115. Pass 5: The last pass converts:
  116.  
  117. 1. STATIC subs to LONG FN and non-static SUBs to LOCAL FN. This is generally all that is necessary to convert SUB over. Refer to the FB handbook and reference manual for more information about LOCAL functions.
  118.  
  119. 2. DIM SHARED variables are moved to the globals section of the program (at the top of the program under the "--Globals---" header.
  120.  
  121. 3. OPENRESFILE "filename" statements are moved to the top of the program as: RESOURCES "filename" statement. A note is added to the line so you can check it. In most cases you will probably just remove it as the RESOURCES statements provides direct access to the resource file. In the off chance that your program is accessing more than one resource file you may want to undo this modification.
  122.  
  123. All QB toolbox commands that access resource files use a ref% number. When the conversion program converts these resource statements it doesn't reference the resource file directly. In most cases this is not needed. However, in the off-chance that the program is accessing multiple resource files, you may require this. Use CALL USERESFILE(ref%) where needed to accomplish this (if you're not doing so already).
  124.  
  125. There are many examples of converting keywords in the file so you should have no problem understanding it.
  126.  
  127. The QB to FB conversion program is included as source code so you can modify it if necessary.
  128.  
  129.  
  130. ------------------------------------------------------- Strings
  131.  
  132. FB strings have a maximum of 255 characters. QB strings can be up to 32k. This can obviously cause some problems. Converting this would be treacherous for the program. The best way to do this would be to write LOCAL FN's that work on string handles. Handles are not limited to 32K so you can have strings of any size. If you are using edit fields with text, the text handle is available with TEHANDLE.
  133.  
  134.  
  135. ------------------------------------------------------- File handling
  136.  
  137. Sequential file handling in nearly identical. Random access file handling will require some conversion. We debated about writing an include to do the conversion but the general concensus was that converting manually would be the safest approach to protecting your data.
  138.  
  139. It is actually easier to do in FB than QB. QB requires that you convert to and from strings using CVI/MKI$ and so on. QB requires use a the FIELD statement to define the position of the data and so on. This is tedious to say the least. Read the file handling section of the Handbook for a complete description of READ and WRITE. You'll be surprised how easy it is.
  140.  
  141. Random Files are not compatible between the programs. You will need to write a program that converts the random file to a text file (PRINT#) and then use LINE INPUT# to read it into FB. From there, write it back out in FB's compressed random format using READ and WRITE.
  142.  
  143.  
  144. ------------------------------------------------------- Include files
  145.  
  146. When using the $INCLUDE meta-command, QB assumes the include file is inserted into that part of the source code. See INCLUDE in the FB reference manual and the Writing programs section of the Handbook for more information about FB Includes. To convert the include file, copy it and paste it into that part of the program where the meta command was. This is the only way to assure all subroutine references are converted correctly.
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.